﻿using NUnit.Framework;
using SpecFlowTfsConnector.Test;
using SpecFlowTfsLinker.Cleaner;
using SpecFlowTfsLinker.Test.Resources;

namespace SpecFlowTfsLinker.Test.Cleaner
{
    [TestFixture]
    public class TestTextToMethodCleaner : UnitTestInitialization
    {
        [Test]
        public void CanCleanTextToPascalCase()
        {
            Assert.That(new TextToMethodCleaner("This is a simple text").Clean(), Is.EqualTo("ThisIsASimpleText"));
        }

        [Test]
        public void CanCleanComplexText()
        {
            Assert.That(new TextToMethodCleaner("     THIS (iS) à S'uPer \\ c.o,!;?m,^p:léx@    text     ").Clean(), Is.EqualTo("ThisIsASuperComplexText"));
        }

        [Test]
        public void CanCleanTextWithParameter()
        {
            AssertMethodCleaning(TestCaseResources.Addition.Given.BaseWihoutGherkin, TestCaseResources.Addition.Given.MethodName);
            AssertMethodCleaning(TestCaseResources.Addition.GivenAnd.BaseWihoutGherkin, TestCaseResources.Addition.GivenAnd.MethodName);
            AssertMethodCleaning(TestCaseResources.Addition.GivenSecondAnd.BaseWihoutGherkin, TestCaseResources.Addition.GivenSecondAnd.MethodName);

            AssertMethodCleaning(TestCaseResources.Addition.When.BaseWihoutGherkin, TestCaseResources.Addition.When.MethodName);
            AssertMethodCleaning(TestCaseResources.Addition.WhenAnd.BaseWihoutGherkin, TestCaseResources.Addition.WhenAnd.MethodName);

            AssertMethodCleaning(TestCaseResources.Addition.Then.BaseWihoutGherkin, TestCaseResources.Addition.Then.MethodName);
            AssertMethodCleaning(TestCaseResources.Addition.ThenAnd.BaseWihoutGherkin, TestCaseResources.Addition.ThenAnd.MethodName);

            AssertMethodCleaning(TestCaseResources.Word.Given.BaseWihoutGherkin, TestCaseResources.Word.Given.MethodName);
            AssertMethodCleaning(TestCaseResources.Word.GivenAnd.BaseWihoutGherkin, TestCaseResources.Word.GivenAnd.MethodName);
            AssertMethodCleaning(TestCaseResources.Word.When.BaseWihoutGherkin, TestCaseResources.Word.When.MethodName);
            AssertMethodCleaning(TestCaseResources.Word.Then.BaseWihoutGherkin, TestCaseResources.Word.Then.MethodName);
           
        }

        private static void AssertMethodCleaning(string statementToClean, string expectedStatement)
        {
            Assert.That(new TextToMethodCleaner(statementToClean).Clean(), Is.EqualTo(expectedStatement));
        }
    }
}